//
//  UIViewController+DLUtils.m
//  DGGUIKit
//
//  Created by dgg_hzk on 2019/11/22.
//

#import "UIViewController+DLUtils.h"
#import <objc/runtime.h>

static const char *DL_automaticallySetModalPresentationStyleKey;

@implementation UIViewController (DLUtils)

//+ (void)load {
//    Method originAddObserverMethod = class_getInstanceMethod(self, @selector(presentViewController:animated:completion:));
//    Method swizzledAddObserverMethod = class_getInstanceMethod(self, @selector(DL_presentViewController:animated:completion:));
//    method_exchangeImplementations(originAddObserverMethod, swizzledAddObserverMethod);
//}
//
//- (void)setDL_automaticallySetModalPresentationStyle:(BOOL)DL_automaticallySetModalPresentationStyle {
//    objc_setAssociatedObject(self, DL_automaticallySetModalPresentationStyleKey, @(DL_automaticallySetModalPresentationStyle), OBJC_ASSOCIATION_ASSIGN);
//}
//
//- (BOOL)DL_automaticallySetModalPresentationStyle {
//    id obj = objc_getAssociatedObject(self, DL_automaticallySetModalPresentationStyleKey);
//    if (obj) {
//        return [obj boolValue];
//    }
//    return [self.class DL_automaticallySetModalPresentationStyle];
//}
//
//+ (BOOL)DL_automaticallySetModalPresentationStyle {
//    if ([self isKindOfClass:[UIImagePickerController class]] || [self isKindOfClass:[UIAlertController class]]) {
//        return NO;
//    }
//    return YES;
//}
//
//- (void)DL_presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
//    if (@available(iOS 13.0, *)) {
//        if (viewControllerToPresent.DL_automaticallySetModalPresentationStyle) {
//            viewControllerToPresent.modalPresentationStyle = UIModalPresentationFullScreen;
//        }
//        [self DL_presentViewController:viewControllerToPresent animated:flag completion:completion];
//    } else {
//        // Fallback on earlier versions
//        [self DL_presentViewController:viewControllerToPresent animated:flag completion:completion];
//    }
//}

@end
